function email(name, domain, subject) 
{
	var addr = name + '@' + domain;	
	document.write('<br><a class=\'footer\' href="mailto:' + addr + '?subject=' + subject + '">[Contact the Webservant]</a>');
}
function link(page)
{		
	window.location=page;
}
function getUrl() 
{
	return window.location;
}
function print_space() 
{
	$(document).ready(function(){
		$('img#logo').css('margin-top','10px');}
	);
}
function returnWidthOfPage() 
{
	var e = window, a = 'inner';
	if ( !( 'innerWidth' in window ) ){
		a = 'client';	
		e = document.documentElement || document.body;
	}	
	return e[ a+'Width' ]
}
function returnHeightOfPage() 
{
	return $(document).height();
}
function readCookie(name) 
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}	
	return null;
}
function setWidthCookie(fakeWidth, page) 
{
	var w = returnWidthOfPage();
	var h = returnHeightOfPage();
	var date = new Date();
	date.setTime(date.getTime()+(1000*24*60*60*1000));
	var exDate = "; expires="+date.toGMTString();
	if ((fakeWidth == null) && (readCookie("userWidthCookie") == null)){	
		if (w > h) {
			document.cookie = 'userWidthCookie='+h+'; expires='+exDate;	
			window.location = page;
		} else {
			document.cookie = 'userWidthCookie='+w+'; expires='+exDate;		
			window.location = page;
		}
	} else if ((fakeWidth != null) && (readCookie("userWidthCookie") != fakeWidth)){
		document.cookie = 'userWidthCookie='+fakeWidth+'; expires='+exDate;			
		window.location = page;	
	} 
}
function hideSafariBar()
{
		setTimeout(function(){
			window.scrollTo(0, 1);		
		},1)
}
function showMore(id)
{
	document.getElementById('infoCard'+id).style.webkitTransform = 'translateX(150%)';
		document.getElementById('infoCard'+id).style.MozTransform = 'translateX(150%)';
		document.getElementById('infoCard'+id).style.OTransform = 'translateX(150%)';
	setTimeout(function(){
		if (document.getElementById("front"+id).style.display != "none"){
			document.getElementById('front'+id).style.display = "none";
			document.getElementById('back'+id).style.display = "block";
		} else {
			document.getElementById('front'+id).style.display = "block";
			document.getElementById('back'+id).style.display = "none";
		}
	}, 500);
	setTimeout(function(){
		document.getElementById('infoCard'+id).style.webkitTransform = 'translateX(0%)';
			document.getElementById('infoCard'+id).style.MozTransform = 'translateX(0%)';
			document.getElementById('infoCard'+id).style.OTransform = 'translateX(0%)';	
		}, 900);
} 
function calculateFee()
{
	if ((document.getElementById("addFee").checked)){
		document.getElementById("feeCovered").innerHTML = parseFloat(document.getElementById("preview").innerHTML).toFixed(2);
		document.getElementById("total").innerHTML = (parseFloat(document.getElementById("donation").innerHTML) + parseFloat(document.getElementById("feeCovered").innerHTML)).toFixed(2);
	} else {
		document.getElementById("feeCovered").innerHTML = "0.00";
		document.getElementById("total").innerHTML = (parseFloat(document.getElementById("donation").innerHTML)).toFixed(2);
	} 
}
function calculatePreviewFee()
{	
	if ((document.getElementById("cash").value != "") && (!isNaN(document.getElementById("cash").value))){
		var taxAmount = ((parseFloat(document.getElementById("cash").value) * .022) + .30);	
		document.getElementById("preview").innerHTML = taxAmount.toFixed(2);
		document.getElementById("donation").innerHTML = (parseFloat(document.getElementById("cash").value)).toFixed(2);
		calculateFee();
	} else {
		document.getElementById("preview").innerHTML = "0.30";
		document.getElementById("donation").innerHTML = "0.00";
		calculateFee();
	}
}
function getTotalDonation()
{
	document.getElementById("finalTotal").value = document.getElementById("total").innerHTML;
}
function checkForOneTime()
{
	if ((document.getElementById("times").value) == 1){
		document.getElementById("recurring").style.display = "none";
		document.getElementById("finalTotal").name = "amount";
		document.getElementById("command").value = "_xclick";
		changePurpose(getPurposeChecked());
	} else {
		document.getElementById("recurring").style.display = "block";
		document.getElementById("finalTotal").name = "a3";
		document.getElementById("command").value = "_xclick-subscriptions";
		changePurpose(getPurposeChecked());
	}
}
function changePurpose(val)
{
	document.getElementById("itemName").value = val;
	if ((document.getElementById("times").value) == 1){
		document.getElementById("itemName").value += " One Time Donation";
	} else {
		document.getElementById("itemName").value += " Recurring Donation";
	}
}
function getPurposeChecked() 
{
	var radios = document.getElementsByName("tier2");
	for (var i=0;i<radios.length;i++){
		if (radios[i].checked){
			return radios[i].value;
		}
	}
}
function submenu(menuName)
{
	$(document).ready(function(){
		$(".subMenu").css("display", "none");
		$("#"+menuName).css("display", "block");
	});
}